$(function(){
	$('#s-foot').load('foot.html');
	$('input:button').each(function(){
		var index = $(this).index();
			$(this).click(function(){
				//console.log(index)
				$('#s-content').html(" ")
				$.get("json/json"+index+".json" ,function(data){
					var a = JSON.stringify(data);
					//var b = JSON.parse(a);
					var $json = JSON.parse(a)
					//console.log(a)
					initPage($json);
				})
	
					//初始化页面
					var initPage = function(json){
						
						//console.log(json.data.length)//8
						//创建一个ul
							var ul = document.createElement("ul");							
							$('#s-content').append('<ul > </ul>')
							//遍历天气信息
							for(var i=0;i<json.data.length;i++){
								//获取某天天气信息
								var currDate = json.data[i];
								
								//console.log(currDate.type)
								
								var imgWeather = 1;
								//
								switch(currDate.type){
									case '1':
										imgWeather = 1;
										break;
									case '2':
										imgWeather = 2;
										break;
									case '3':
										imgWeather = 3;
										break;
									case '4':
										imgWeather = 4;
										break;
									case '5':
										imgWeather = 5;
										break;
									case '6':
										imgWeather = 6;
										break;
									case '7':
										imgWeather = 7;
										break;
									case '8':
										imgWeather = 8;
										break;
								}
								//创建Li
								var li = document.createElement("li");
								$('ul').append('<li id="s-g"></li>');
							
								$('li').eq(i).html( 
								"<img src = 'src/img/list"+index+"/" + imgWeather + ".jpg' id='img'/>"
								 +"<p id='pony'>"+currDate.text1 + "</p>" 
								+ "<p id='wenzi'>"+currDate.text2 + "</p>" 
								+ "<p id='price'>"+currDate.text3 + "</p>" 
								+ "<p id='s-c'>"+currDate.text4 + "</p>" 
								+"<img src = 'src/img/index/l-logo.png' id='l-logo'/>"
								+"<img src = 'src/img/index/btn.png' />"
								)
								
								
								
							}

					};
			})
	})
		
					$.get("json/json1.json" ,function(data){
						var a = JSON.stringify(data);
						//var b = JSON.parse(a);
						var $json = JSON.parse(a)
						//console.log(a)
						initPage($json);
					})
	
					//初始化页面
					var initPage = function(json){
						
						//console.log(json.data.length)//8
						//创建一个ul
							//var ul = document.createElement("ul");							
							$('#s-content').append('<ul ></ul>')
							//遍历天气信息
							for(var i=0;i<json.data.length;i++){
								//获取某天天气信息
								var currDate = json.data[i];
								
								console.log(currDate.type)
								
								var imgWeather = 1;
								//图片
								switch(currDate.type){
									case '1':
										imgWeather = 1;
										break;
									case '2':
										imgWeather = 2;
										break;
									case '3':
										imgWeather = 3;
										break;
									case '4':
										imgWeather = 4;
										break;
									case '5':
										imgWeather = 5;
										break;
									case '6':
										imgWeather = 6;
										break;
									case '7':
										imgWeather = 7;
										break;
									case '8':
										imgWeather = 8;
										break;
								}
								//创建Li
								//var li = document.createElement("li");
								$('ul').append('<li id="s-g"></li>');
							
								$('li').eq(i).html( 
								"<img src = 'src/img/list0/" + imgWeather + ".jpg' id='img'/>"
								 +"<p id='pony'>"+currDate.text1 + "</p>" 
								+ "<p id='wenzi'>"+currDate.text2 + "</p>" 
								+ "<p id='price'>"+currDate.text3 + "</p>" 
								+ "<p id='s-c'>"+currDate.text4 + "</p>" 
								+"<img src = 'src/img/index/l-logo.png' id='l-logo'/>"
								+"<img src = 'src/img/index/btn.png' />"
								)
							
							};
	
					}
})
